<template>
  <div id="app">
    <div v-if="token != null">
      <header>购物车<span v-show="cartList.length > 0">编辑</span></header>
      <div v-if="cartList.length == 0">
        <section>
          <div id="top1">
            <img src="../assets/img/bg_emply.png" />
            <p>亲，暂无数据</p>
            <button>去逛逛</button>
          </div>
          <p id="middle1">为你推荐</p>
          <main>
            <Card />
          </main>
        </section>
      </div>
      <div v-else>
        <Product ref="one" />
        <!-- <Product/>
          <Product/> -->
      </div>
    </div>
    <div v-if="token === null">
      <section>
        <div id="top">
          <span>您可以在登陆后同步账户中的商品</span><a>登录</a>
        </div>
        <p id="middle">为你推荐</p>
        <Card />
      </section>
    </div>
    <div id="bg">到底了~~~~~</div>
  </div>
</template>
<script>
import Card from "@/components/card.vue";
import Product from "@/components/product.vue";
import "@/assets/css/base.css";

export default {
  components: { Card, Product },
  data() {
    return {
      sum: "",
      count: "",
      isarr: false,
      cartList: [1],
      // cartList:this.$refs.data.cartList,
      token: localStorage.getItem("token"),
    };
  },
  mounted() {
    // console.log(this.$refs.one.count);
    console.log(this.$refs);
    // console.log(this.$refs.one._data.cartList);
  },
};
</script>
<style lang="scss" scoped>
body {
  width: 100%;
  height: 100%;
}
#bg {
  background-color: #f4f4f4;
  height: 1.5rem;
  line-height: 1rem;
  padding-bottom: 1.5rem;
}
#app {
  /* font-family: Avenir, Helvetica, Arial, sans-serif; */
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  text-align: center;
  color: #2c3e50;

  /* background-color: blue */
  display: flex;
  flex-direction: column;
  height: 100%;
  width: 100%;
}

header {
  /* background-color: pink; */
  width: 100%;
  height: 1rem;
  font-size: 0.35rem;
  line-height: 1rem;

  span {
    position: absolute;
    right: 0.5rem;
  }
}
section {
  /* background-color: yellow; */
  background-color: #f4f4f4;

  width: 100%;
  #top {
    width: 100%;
    height: 0.8rem;

    display: flex;
    border-top: solid 0.02rem #f3d9d9;
    border-bottom: solid 0.02rem #f3d9d9;
    align-items: center;
    justify-content: flex-end;

    a {
      display: block;
      width: 1rem;
      margin: 0 0.3rem;
      border: red solid 0.025rem;
      border-radius: 0.3rem;
      border-color: red;
    }
  }
  #middle {
    font-weight: bolder;
    font-size: 0.4rem;
    margin-top: 4.5rem;
    margin-left: -5rem;
    margin-bottom: 0.35rem;
  }
  #top1 {
    img {
      width: 2rem;
      height: 2rem;
      margin-top: 0.6rem;
      margin-bottom: 0.4rem;
    }
    p {
      margin-bottom: 0.3rem;
    }
    button {
      width: 2.5rem;
      height: 0.8rem;
      border: 0;
      border-radius: 0.5rem;
      background-color: #f06c70;
      color: #f4f4f4;
    }
  }
  #middle1 {
    font-weight: bolder;
    font-size: 0.4rem;
    margin-top: 1rem;
    margin-left: -5rem;
    margin-bottom: -0.3rem;
  }
  main {
    display: flex;
    justify-content: space-around;
    div {
      width: 100%;
    }
  }
}
</style>
